/* Copyright (C) 2010 Luca Piccinelli
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* 
 * File:   formatters.cpp
 * Author: picci
 *
 * Created on November 27, 2010, 12:26 PM
 */

#include "formatters/formatters.h"

namespace NAMESPACE{

//  _____________________________________________________
// |   Standard constructors                             |
// |_____________________________________________________|

AbstractFormatter::~AbstractFormatter(){
    delete key;
}
AbstractFormatter::AbstractFormatter() : Formatter(),
                                         key(new IOKey()){}
AbstractFormatter::AbstractFormatter(const AbstractFormatter& af) : Formatter(af),
                                                                    key(new IOKey(*(af.key))){}
AbstractFormatter& AbstractFormatter::operator=(const AbstractFormatter& af){
    if(this == &af) return *this;
    *key = *(af.key);
    return *this;
}
// ......................................................

//  _____________________________________________________
// |   Other constructors                                |
// |_____________________________________________________|

AbstractFormatter::AbstractFormatter(const IOKey& k) : Formatter(),
                                                       key(new IOKey(k)){}

// ......................................................

Formatter& AbstractFormatter::set_key(const IOKey& k){
    *key = k;
    return *this;
}

const IOKey& AbstractFormatter::get_key() const{
    return *key;
}

bool AbstractFormatter::operator==(const Formatter& f) const{
    const AbstractFormatter& tmp_af = dynamic_cast<const AbstractFormatter&>(f);
    return *key == *(tmp_af.key);
}
bool AbstractFormatter::operator!=(const Formatter& f) const{
    return !(AbstractFormatter::operator==(f));
}

}
